library(plotly)
library(magrittr)

# 1. create interactive plots from plotly

##### china #####
china1<-plot_ly(type = 'scattergeo', mode = 'markers+text', locationmode = 'China',
                text = c('Anhui', 'Beijing', 'Chongqing', 'Fujian', 'Gansu', 'Guangdong', 'Guangxi','Guizhou','Hainan','Hebei','Helongjiang', 'Henan', 'Hubei', 'Hunan', 'Inner Mongolia', 'Jiangsu','Jiangxi', 'Jilin', 'Liaoning', 'Qinghai','Shanxi', 'Shandong', 'Shanghai', 'Shanxi','Sichuan', 'Tianjin', 'Tibet', 'Xinjiang', 'Yunnan', 'Zhejiang' ) ,
                lat = c(31.8611, 39.9042, 29.5630, 26.1008, 36.0596, 23.1322, 22.8155, 26.5992, 20.0174, 38.0371, 45.7424, 34.7655,  30.5466, 28.1124, 40.8174, 32.0617, 28.6757, 43.8965, 41.8362, 36.6209,37.8735, 36.6685, 31.2304, 37.8735, 30.6512, 39.0842, 29.6475, 43.7930, 25.0458, 30.2674),
                lon = c(117.2849, 116.4074, 106.5516, 119.2951,103.8264, 113.2665, 108.3275, 106.7063,110.3492, 114.4687, 126.6617, 113.7536, 114.3417, 112.9838, 111.7663, 118.7632,115.9092, 125.3259, 123.4314, 101.7803, 112.5627, 117.0204, 121.4737, 112.5627, 104.0759, 117.2010, 91.1175, 87.6277, 102.7100, 120.1528),
                marker = list(
                  size = c(7,31,4,6,4,63,10,7,3,3,4,10,6,8,2,7,6,4,8,9,9,12,13,2,29,9,7,6,13,11), 
                  color = c(7,31,4,6,4,63,10,7,3,3,4,10,6,8,2,7,6,4,8,9,9,12,13,2,29,9,7,6,13,11), 
                  cmin = 0, cmax = 60,colorscale = 'greens',
                  # colorbar = list(showticksuffix= 'last',thickness = 8, len = 0.5, xanchor ="left", y = 0.35),
                  line= list(color = 'red'))) %>% layout(hovermode = FALSE,
                                                         title = "Human-coded",
                                                         font = list(size = 6,color = 'black'), titlefont = list(size = 16),
                                                         geo = list(resolution = 50, scope = 'asia',
                                                                    lataxis = list(range = c(17, 54)),lonaxis = list(range = c(73, 135)),
                                                                    showland = TRUE,landcolor = toRGB("#D9D9D9"),
                                                                    countrycolor = toRGB("grey"),countrywidth = 1.5,
                                                                    subunitcolor = 'black',projection = list(type = "mercator"))  )


china2<-plot_ly(type = 'scattergeo', mode = 'markers+text', locationmode = 'China',
                text = c('Anhui', 'Beijing', 'Chongqing', 'Fujian', 'Gansu', 'Guangdong', 'Guangxi','Guizhou','Hainan','Hebei','Helongjiang', 'Henan', 'Hubei', 'Hunan', 'Inner Mongolia', 'Jiangsu','Jiangxi', 'Jilin', 'Liaoning', 'Qinghai','Shanxi', 'Shandong', 'Shanghai', 'Shanxi','Sichuan', 'Tianjin', 'Tibet', 'Xinjiang', 'Yunnan', 'Zhejiang'),
                lat = c(31.8611, 39.9042, 29.5630, 26.1008, 36.0596, 23.1322, 22.8155, 26.5992, 20.0174, 38.0371, 45.7424, 34.7655,  30.5466, 28.1124, 40.8174, 32.0617, 28.6757, 43.8965, 41.8362, 36.6209,37.8735, 36.6685, 31.2304, 37.8735, 30.6512, 39.0842, 29.6475, 43.7930, 25.0458, 30.2674),
                lon = c(117.2849, 116.4074, 106.5516, 119.2951,103.8264, 113.2665, 108.3275, 106.7063,110.3492, 114.4687, 126.6617, 113.7536, 114.3417, 112.9838, 111.7663, 118.7632,115.9092, 125.3259, 123.4314, 101.7803, 112.5627, 117.0204, 121.4737, 112.5627, 104.0759, 117.2010, 91.1175, 87.6277, 102.7100, 120.1528),
                marker = list(
                  size = c(6,29,2,7,3,68,8,7,2,8,3,7,3,9,2,8,6,4,10,7,6,12,9,2,24,4,9,8,11,11), 
                  color = c(6,29,2,7,3,68,8,7,2,8,3,7,3,9,2,8,6,4,10,7,6,12,9,2,24,4,9,8,11,11), 
                  cmin = 0, cmax = 60,colorscale = 'greens',
                  # colorbar = list(showticksuffix= 'last' ,thickness = 8, len = 0.5, xanchor ="left", y = 0.35),
                  line= list(color = 'red')))  %>% layout(hovermode = FALSE,
                                                          title = "Proposed Method",
                                                          font = list(size = 6,  scope ="asia", color = 'black'), titlefont = list(size = 16 ),
                                                          geo = list(resolution = 50,scope = 'asia',lataxis = list(range = c(17, 54)),lonaxis = list(range = c(73, 135)),showland = TRUE,landcolor = toRGB("#D9D9D9"),countrycolor = toRGB("grey"),countrywidth = 1.5,subunitcolor = 'black',projection = list(type = "mercator"))
                  )

china3<-plot_ly(type = 'scattergeo', mode = 'markers+text', locationmode = 'China',
                text =c('Anhui', 'Beijing', 'Chongqing', 'Fujian', 'Gansu', 'Guangdong', 'Guangxi','Guizhou','Hainan','Hebei','Helongjiang', 'Henan', 'Hubei', 'Hunan', 'Inner Mongolia', 'Jiangsu','Jiangxi', 'Jilin', 'Liaoning', 'Qinghai','Shanxi', 'Shandong', 'Shanghai', 'Shanxi','Sichuan', 'Tianjin', 'Tibet', 'Xinjiang', 'Yunnan', 'Zhejiang'),
                lat = c(31.8611, 39.9042, 29.5630, 26.1008, 36.0596, 23.1322, 22.8155, 26.5992, 20.0174, 38.0371, 45.7424, 34.7655,  30.5466, 28.1124, 40.8174, 32.0617, 28.6757, 43.8965, 41.8362, 36.6209,37.8735, 36.6685, 31.2304, 37.8735, 30.6512, 39.0842, 29.6475, 43.7930, 25.0458, 30.2674),
                lon = c(117.2849, 116.4074, 106.5516, 119.2951,103.8264, 113.2665, 108.3275, 106.7063,110.3492, 114.4687, 126.6617, 113.7536, 114.3417, 112.9838, 111.7663, 118.7632,115.9092, 125.3259, 123.4314, 101.7803, 112.5627, 117.0204, 121.4737, 112.5627, 104.0759, 117.2010, 91.1175, 87.6277, 102.7100, 120.1528),
                marker = list(
                  size = c(15,63,2,3,5,29,0,10,2,2,2,3,8,6,1,6,3,8,2,4,5,5,10,9,14,3,12,4,5,11), 
                  color = c(15,63,2,3,5,29,0,10,2,2,2,3,8,6,1,6,3,8,2,4,5,5,10,9,14,3,12,4,5,11), 
                  cmin = 0, cmax = 60,colorscale = 'greens',
                  # colorbar = list(showticksuffix= 'last' ,thickness = 3, len = 0.3, xanchor ="left", y = 0.5),
                  line= list(color = 'red'))) %>%  layout(hovermode = FALSE,
                                                          title = "Existing Method (ICEWS)",
                                                          font = list(size = 6,  color = 'black'), 
                                                          titlefont = list(size = 16 ),
                                                          geo = list(resolution = 50,scope = 'asia',lataxis = list(range = c(17, 54)),
                                                                     lonaxis = list(range = c(73, 135)),showland = TRUE,
                                                                     landcolor = toRGB("#D9D9D9"),countrycolor = toRGB("grey"),
                                                                     countrywidth = 1.5,subunitcolor = 'black',projection = list(type = "mercator"))   )



##### DRC #####
drc1<-plot_ly(type = 'scattergeo', mode = 'markers+text', locationmode = 'DRC',
              text = c('Bandundu','Bas Congo','Equateur','Kasai Occidental','Kasai Oriental','Katanga','Kinshasa','Maniema','North Kivu','Orientale','South Kivu'),
              lat = c(-4.163679,-5.2365685,0.5640,-5.3205473,-2.8437453,-8.8851145,-4.4419311,-3.0730929,-0.7917729,1.6406296,-3.011658),
              lon = c(18.80762,13.9144,20.3309,21.85686,23.38235,26.41939,15.26629,26.04139,29.04599,26.41939,28.29943),
              marker = list(
                size = c(1,5,3,2,1,15,33,2,114,46,34), 
                color = c(1,5,3,2,1,15,33,2,114,46,34),
                cmin = 0, cmax = 120,colorscale = 'greens',
                # colorbar = list(showticksuffix= 'last',thickness = 8, len = 0.5, xanchor ="left", y = 0.4),
                line= list(color = 'red'))) %>%   layout(hovermode = FALSE,
                                                         title = "Human-coded",
                                                         font = list(size = 6,  scope ="africa", color = 'black'), titlefont = list(size = 16 ),
                                                         geo = list(resolution = 60,scope = 'africa',lataxis = list(range = c(-12, 6)),lonaxis = list(range = c(11,32)),showland = TRUE,landcolor = toRGB("#D9D9D9"),countrycolor = toRGB("grey"),countrywidth = 1.5,subunitcolor = 'black',projection = list(type = "mercator"))  )

drc2<-plot_ly(type = 'scattergeo', mode = 'markers+text', locationmode = 'DRC',
              text = c('Bandundu','Bas Congo','Equateur','Kasai Occidental','Kasai Oriental','Katanga','Kinshasa','Maniema','North Kivu','Orientale','South Kivu'),
              lat = c(-4.163679,-5.2365685,-1.831239,-5.3205473,-2.8437453,-8.8851145,-4.4419311,-3.0730929,-0.7917729,1.6406296,-3.011658),
              lon = c(18.80762,13.9144,-78.18341,21.85686,23.38235,26.41939,15.26629,26.04139,29.04599,26.41939,28.29943),
              marker = list(
                size = c(0,3,4,2,1,13,37,2,118,44,29), 
                color = c(0,3,4,2,1,13,37,2,118,44,29), 
                cmin = 0, cmax = 100,colorscale = 'greens',
                # colorbar = list(showticksuffix= 'last',thickness = 8, len = 0.5, xanchor ="left", y = 0.25),
                line= list(color = 'red'))) %>% layout(hovermode=FALSE,
                                                       title = "Proposed Method",
                                                       font = list(size = 6,  scope ="africa", color = 'black'), titlefont = list(size = 16 ),
                                                       geo = list(resolution = 60,scope = 'africa',lataxis = list(range = c(-12, 6)),lonaxis = list(range = c(11,32)),showland = TRUE,landcolor = toRGB("#D9D9D9"),countrycolor = toRGB("grey"),countrywidth = 1.5,subunitcolor = 'black',projection = list(type = "mercator")) )

drc3<-plot_ly(type = 'scattergeo', mode = 'markers+text', locationmode = 'DRC',
              text = c('Bandundu','Bas Congo','Equateur','Kasai Occidental','Kasai Oriental','Katanga','Kinshasa','Maniema','North Kivu','Orientale','South Kivu'),
              lat = c(-4.163679,-5.2365685,0.5640,-5.3205473,-2.8437453,-8.8851145,-4.4419311,-3.0730929,-0.7917729,1.6406296,-3.011658),
              lon = c(18.80762,13.9144,20.3309,21.85686,23.38235,26.41939,15.26629,26.04139,29.04599,26.41939,28.29943),
              marker = list(
                size = c(2,2,1,2,2,8,56,1,83,30,28), 
                color = c(2,2,1,2,2,8,56,1,83,30,28), 
                cmin = 0, cmax = 100,colorscale = 'greens',
                # colorbar = list(showticksuffix= 'last',thickness = 8, len = 0.5, xanchor ="left", y = 0.25),
                line= list(color = 'red'))) %>%    layout(hovermode=FALSE,
                                                          title = "Existing Method (ICEWS)",
                                                          font = list(size = 6,  scope ="africa", color = 'black'), titlefont = list(size = 16 ),
                                                          geo = list(resolution = 60,scope = 'africa',lataxis = list(range = c(-12, 6)),lonaxis = list(range = c(11,32)),showland = TRUE,landcolor = toRGB("#D9D9D9"),countrycolor = toRGB("grey"),countrywidth = 1.5,subunitcolor = 'black',projection = list(type = "mercator")) )


#### syria ####
syria1<-plot_ly(type = 'scattergeo', mode = 'markers+text', locationmode = 'syria',
                text = c('Aleppo', 'Damascus', 'Daraa', 'Deirezzor', 'Hama', 'Hasakah', 'Homs', 'Idlib', 'Latakia', 'Quneitra', 'Raqqah', 'Rif Dimashq', 'As-Suwayda', 'Tartus'),
                lat = c(36.2021,33.5138,32.6264,35.3297,35.1409,36.5079,34.73243,35.9310,35.54071,33.1256,35.9594,33.6167,32.8129,34.89593),
                lon = c(37.13426,36.2765,36.1033,40.1350,36.7552,40.7463,36.7137,36.6418,35.89527,35.9239,38.9981,37.0541,36.7663,35.88665),
                marker = list(
                  size = c(129,22,14,6,22,9,13,36,17,6,18,25,2,1),
                  sizemin = 5,sizemax=129,
                  color = c(129,22,14,6,22,9,13,36,17,6,18,25,2,1),
                  cmin = 0, cmax = 140,colorscale = 'greens',
                  # colorbar = list(showticksuffix= 'last',thickness = 8, len = 0.5, xanchor ="left", y = 0.4),
                  line= list(color = 'red'))) %>%      layout(hovermode=FALSE,
                                                              title = "Human-coded",
                                                              font = list(size = 6,  color = 'black'), titlefont = list(size = 16 ),
                                                              geo = list(resolution = 60,scope = 'asia',lataxis = list(range = c(32, 37.2)),lonaxis = list(range = c(35,42.4)),showland = TRUE,landcolor = toRGB("#D9D9D9"),countrycolor = toRGB("grey"),countrywidth = 1.5,subunitcolor = 'black',projection = list(type = "mercator")))

syria2<-plot_ly(type = 'scattergeo', mode = 'markers+text', locationmode = 'syria',
                text = c('Aleppo', 'Damascus', 'Daraa', 'Deirezzor', 'Hama', 'Hasakah', 'Homs', 'Idlib', 'Latakia', 'Quneitra', 'Raqqah', 'Rif Dimashq', 'As-Suwayda', 'Tartus'),
                lat = c(36.2021,33.5138,32.6264,35.3297,35.1409,36.5079,34.73243,35.9310,35.54071,33.1256,35.9594,33.6167,32.8129,34.89593),
                lon = c(37.13426,36.2765,36.1033,40.1350,36.7552,40.7463,36.7137,36.6418,35.89527,35.9239,38.9981,37.0541,36.7663,35.88665),
                marker = list(  size = c(139,35,11,5,17,8,5,38,14,7,9,23,2,1), 
                                sizemin = 5,sizemax=139,
                                color = c(139,35,11,5,17,8,5,38,14,7,9,23,2,1), 
                                cmin = 0, cmax = 100,colorscale = 'greens',
                                # colorbar = list(showticksuffix= 'last',thickness = 8, len = 0.5, xanchor ="left", y = 0.25),
                                line= list(color = 'red'))) %>%     layout(hovermode=FALSE,
                                                                           title = "Proposed Method",
                                                                           font = list(size = 6,  color = 'black'), titlefont = list(size = 16 ),
                                                                           geo = list(resolution = 60,scope = 'asia',lataxis = list(range = c(32, 37.2)),lonaxis = list(range = c(35,42.4)),showland = TRUE,landcolor = toRGB("#D9D9D9"),countrycolor = toRGB("grey"),countrywidth = 1.5,subunitcolor = 'black',projection = list(type = "mercator")) )

syria3<-plot_ly(type = 'scattergeo', mode = 'markers+text', locationmode = 'syria',
                text =c('Aleppo','Damascus','Daraa','Hama','Idlib','Latakia','Quneitra','Raqqah'),
                lat = c(36.2021,33.5138,32.6264,35.1409,35.9310,35.54071,33.1256,35.9594),
                lon = c(37.13426,36.2765,36.1033,36.7552,36.6418,35.89527,35.9239,38.9981),
                marker = list( size = c(67,14,1,2,2,3,4,2), 
                               sizemin = 5,sizemax=67,
                               color = c(67,14,1,2,2,3,4,2), 
                               cmin = 0, cmax = 140,colorscale = 'greens',
                               # colorbar = list(showticksuffix= 'last',thickness = 8, len = 0.5, xanchor ="left", y = 0.25),
                               line= list(color = 'red'))) %>%    layout(hovermode=FALSE,
                                                                         title = "Existing Method (Phoenix)",
                                                                         font = list(size = 6,  color = 'black'), titlefont = list(size = 16 ),
                                                                         geo = list(resolution = 60,scope = 'asia',lataxis = list(range = c(32, 37.2)),lonaxis = list(range = c(35,42.4)),showland = TRUE,landcolor = toRGB("#D9D9D9"),countrycolor = toRGB("grey"),countrywidth = 1.5,subunitcolor = 'black',projection = list(type = "mercator")) )

#### Colombia #####

colombia1<-plot_ly(type = 'scattergeo', mode = 'markers+text', locationmode = 'colombia',
                   text = c('Amazonas', 'Antioquia', 'Atlantico', 'Bogota', 'Bolivar', 'Boyaca', 'Caqueta', 'Cauca', 'Choco', 'Cordoba', 'Cundinamarca', 'Guaviare', 'Huila', 'La Guajira', 'Magdalena', 'Meta', 'Narino', 'Norte De Saantander', 'Putumayo', 'Quindio', 'Risaralda', 'Santander', 'Sucre', 'Tolima', 'Valledelcaauca'),
                   lat = c(-1.4429123,7.1986064,10.6966159,4.6109886,8.5704382,5.654511,0.869892,2.6049813,5.1528033,8.149293,5.026003,2.043924,2.3359349,11.3547743,10.2413014,3.2719904,1.289151,7.7462831,0.4359506,4.4610191,5.5158475,6.6437076,9.113977,4.0925168,3.6008893),
                   lon = c(-71.5724,-75.34122,-74.8741,-74.072092,-73.900122,-73.362003,-73.84191,-76.9959652,-76.8259652,-75.77405,-74.03001,-72.33111,-75.2276699,-72.52048,-74.2056612,-73.08775,-77.35794,-72.4988069,-75.52767,-75.66736,-75.9927652,-73.65362,-75.823283,-75.15454,-76.6412712),
                   marker = list( size = c(2,34,9,107,16,5,11,24,2,4,4,4,11,2,3,8,6,18,13,1,3,15,1,8,23),
                                  color = c(2,34,9,107,16,5,11,24,2,4,4,4,11,2,3,8,6,18,13,1,3,15,1,8,23),
                                  cmin = 0, cmax = 130,colorscale = 'greens',
                                  # colorbar = list(showticksuffix= 'last',thickness = 8, len = 0.5, xanchor ="left", y = 0.25),
                                  line= list(color = 'red'))) %>% layout(hovermode=FALSE,
                                                                         title = "Human-coded",
                                                                         font = list(size = 6, color = 'black'), titlefont = list(size = 16 ),
                                                                         geo = list(resolution = 90,scope = 'south america',lataxis = list(range = c(-2, 12.00)),lonaxis = list(range = c(-79.00, -67.00)),showland = TRUE,landcolor = toRGB("#D9D9D9"),countrycolor = toRGB("grey"),countrywidth = 1.5,subunitcolor = 'black',projection = list(type = "mercator")) )

colombia2<-plot_ly(type = 'scattergeo', mode = 'markers+text', locationmode = 'colombia',
                   text = c('Amazonas','Antioquia','Atlantico','Bogota','Bolivar',
                            'Boyaca','Caldas','Caqueta','Cauca','Cesar', 
                            'Choco','Cordoba','Cundinamarca','Guaviare','Huila',
                            'La Guajira','Magdalena','Meta','Narino','Norte de Santander',
                            'Putumayo','Quindio', 'Risaralda','Santander','Sucre',
                            'Tolima','Valle del Cauca'),
                   lat = c(-1.4429123,7.1986064,10.6966159,4.6109886,8.5704382,
                           5.654511,5.2983,0.869892,2.6049813,9.3373,
                           5.1528033,8.149293,5.026003,2.0439, 2.3359349,
                           11.3547743,10.2413014,3.2719904,1.289151,7.7462831,
                           0.4359506,4.4610,5.5158475,6.6437076,9.113977,4.0925168,3.6008893),
                   lon = c(-71.5723953,-75.3412179,-74.8741045,-74.072092,-73.900122,
                           -73.362003,-75.2479,-73.8419063,-76.9959652,-73.6536,
                           -76.8259652,-75.77405,-74.0300122,-72.3311,-75.2276699,
                           -72.5204827,-74.2056612,-73.087749,-77.35794,-72.4988069,
                           -75.5276699,-75.6674,-75.9927652,-73.6536209,-75.823283,-75.1545381,-76.6412712),
                   marker = list(
                     size = c(2,26,9,115,21,8,5,12,24,1,1,7,5,2,7,3,5,11,5,13,9,1,1,12,3,6,30), 
                     sizemin=5,sizemax=115,
                     color = c(2,26,9,115,21,8,5,12,24,1,1,7,5,2,7,3,5,11,5,13,9,1,1,12,3,6,30),
                     cmin = 0, cmax = 115,colorscale = 'greens',
                     # colorbar = list(showticksuffix= 'last',thickness = 8, len = 0.5, xanchor ="left", y = 0.25),
                     line= list(color = 'red'))) %>%    layout(hovermode=FALSE,
                                                               title = "Proposed Method",
                                                               font = list(size = 6, color = 'black'), titlefont = list(size = 16 ),
                                                               geo = list(resolution = 90,scope = 'south america',lataxis = list(range = c(-2, 12.00)),lonaxis = list(range = c(-79.00, -67.00)),showland = TRUE,landcolor = toRGB("#D9D9D9"),countrycolor = toRGB("grey"),countrywidth = 1.5,subunitcolor = 'black',projection = list(type = "mercator"))
                     )

colombia3<-plot_ly(type = 'scattergeo', mode = 'markers+text', locationmode = 'colombia',
                   text = c('Antioquia','Arauca','Atlantico','Bogota','Bolivar','Boyaca','Casanare','Cauca','Cordoba','La Guajira','Magdalena','Meta','Narino','Norte de Santander','Putumayo','Santander','Sucre','Valle del Cauca'),
                   lat = c(7.1986064,6.5473, 10.6966159,4.6109886,8.5704382,5.654511,5.7589,2.6049813,8.149293,11.3547743,10.2413014,3.2719904,1.289151,7.7462831,0.4359506,6.6437076,9.113977,3.6008893),
                   lon = c(-75.3412179,-71.0022,-74.8741045,-74.072092,-73.900122,-73.362003,-71.5724,-76.9959652,-75.77405,-72.5204827,-74.2056612,-73.087749,-77.35794,-72.4988069,-75.5276699,-73.6536209,-75.823283,-76.6412712),
                   marker = list(
                     size = c(14,7,5,126,6,1,8,2,2,3,10,3,2,7,3,4,7,26),
                     color = c(14,7,5,126,6,1,8,2,2,3,10,3,2,7,3,4,7,26),
                     cmin = 0, cmax = 100,colorscale = 'greens',
                     # colorbar = list(showticksuffix= 'last',thickness = 8, len = 0.5, xanchor ="left", y = 0.25),
                     line= list(color = 'red'))) %>%    layout(hovermode=FALSE,
                                                               title = "Existing Method (ICEWS)",# change
                                                               font = list(size = 6, color = 'black'), titlefont = list(size = 16 ),
                                                               geo = list(resolution = 90,scope = 'south america',lataxis = list(range = c(-2, 12.00)),lonaxis = list(range = c(-79.00, -67.00)),showland = TRUE,landcolor = toRGB("#D9D9D9"),countrycolor = toRGB("grey"),countrywidth = 1.5,subunitcolor = 'black',projection = list(type = "mercator"))
                     )

##########################


# set plotly usernames and api
Sys.setenv("plotly_username" = "lostinspace")
Sys.setenv("plotly_api_key" = "jugE2dp2T0X0DLwHHsSk")


# 2. export static images from interactive plotly
plotly_IMAGE(china1, format = "png", out_file = paste0(dirname(rstudioapi::getActiveDocumentContext()$path), "/china1.png"), width = 300, height = 300,  scale = 1 ) 
plotly_IMAGE(china2, format = "png", out_file = paste0(dirname(rstudioapi::getActiveDocumentContext()$path), "/china2.png"), width = 300, height = 300,  scale = 1  ) 
plotly_IMAGE(china3, format = "png", out_file = paste0(dirname(rstudioapi::getActiveDocumentContext()$path), "/china3.png"), width = 300, height = 300,  scale = 1  ) 


plotly_IMAGE(drc1, format = "png", out_file = paste0(dirname(rstudioapi::getActiveDocumentContext()$path), "/drc1.png"), width = 300, height = 300,  scale = 1 ) 
plotly_IMAGE(drc2, format = "png", out_file = paste0(dirname(rstudioapi::getActiveDocumentContext()$path), "/drc2.png"), width = 300, height = 300,  scale = 1  ) 
plotly_IMAGE(drc3, format = "png", out_file = paste0(dirname(rstudioapi::getActiveDocumentContext()$path), "/drc3.png"), width = 300, height = 300,  scale = 1  ) 


plotly_IMAGE(syria1, format = "png", out_file = paste0(dirname(rstudioapi::getActiveDocumentContext()$path), "/syria1.png"), width = 300, height = 300,  scale = 1 ) 
plotly_IMAGE(syria2, format = "png", out_file = paste0(dirname(rstudioapi::getActiveDocumentContext()$path), "/syria2.png"), width = 300, height = 300,  scale = 1  ) 
plotly_IMAGE(syria3, format = "png", out_file = paste0(dirname(rstudioapi::getActiveDocumentContext()$path), "/syria3.png"), width = 300, height = 300,  scale = 1  ) 


plotly_IMAGE(colombia1, format = "png", out_file = paste0(dirname(rstudioapi::getActiveDocumentContext()$path), "/colombia1.png"), width = 300, height = 300,  scale = 1 ) 
plotly_IMAGE(colombia2, format = "png", out_file = paste0(dirname(rstudioapi::getActiveDocumentContext()$path), "/colombia2.png"), width = 300, height = 300,  scale = 1  ) 
plotly_IMAGE(colombia3, format = "png", out_file = paste0(dirname(rstudioapi::getActiveDocumentContext()$path), "/colombia3.png"), width = 300, height = 300,  scale = 1  ) 